#include <QApplication>
#include <QDateTime>
#include <QDebug>
#include <QProcess>
#include <QJsonDocument>
#include <QJsonObject>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QProcess process;
    process.start("docker", QStringList() << "search" << "jenkins" << "--format" << "{{json .}}");
    process.waitForFinished();
    while (process.canReadLine()) {
        QString line = process.readLine();
        QJsonDocument doc = QJsonDocument::fromJson(line.toUtf8());
        if (!doc.isObject()) {
            continue;
        }
        
        QJsonObject obj = doc.object();

        auto Description = obj.value("Description").toString();
        auto IsAutomated = obj.value("IsAutomated").toString();
        auto IsOfficial = obj.value("IsOfficial").toString();
        auto Name = obj.value("Name").toString();
        auto StarCount = obj.value("StarCount").toString();

        qDebug() << Name << Description;
    }

    return 0;
}

/**
{
    "Description": "DEPRECATED; use \"jenkins/jenkins:lts\" instead",
    "IsAutomated": "false",
    "IsOfficial": "true",
    "Name": "jenkins",
    "StarCount": "5702"
}
 */
